package com.baizhi.util;

import java.util.List;

public class PageBean<T> {
    private int pageIndex=1;//本页的页码
    private int pageMax;//最大页数
    private int pageSize=5;//每页条数
    private List<T> list;//返回集合对象类型
    private int count;//数据库的数据总共有多少。
    private int start;//起始条数
    private int end;//最后条数
    private  boolean  nextPage;
    private boolean   shangpage;
    private int next;//如果是下一页返回值中pageIndex+1
    private int pre;//如果是上一页返回值中pageIndex-1

    public int getNext() {
        return pageIndex+1;
    }

    public void setNext(int next) {
        this.next = next;
    }

    public int getPre() {
        return pageIndex-1;
    }

    public void setPre(int pre) {
        this.pre = pre;
    }

    public boolean isNextPage() {
        return getPageMax()>pageIndex;
    }

    public void setNextPage(boolean nextPage) {
        this.nextPage = nextPage;
    }

    public boolean isShangpage() {
        return pageIndex>1;
    }

    public void setShangpage(boolean shangpage) {
        this.shangpage = shangpage;
    }

    public int getStart() {
        return (pageIndex-1)*pageSize+1;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public int getEnd() {
        return getPageSize()*pageIndex;
    }

    public void setEnd(int end) {
        this.end = end;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public void setPageMax(int pageMax) {
        this.pageMax = pageMax;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public int getPageMax() {
        return count%pageSize==0?count/pageSize:count/pageSize+1;
    }

    public int getPageSize() {
        return pageSize;
    }

    public List<T> getList() {
        return list;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "pageIndex=" + pageIndex +
                ", pageMax=" + getPageMax() +
                ", pageSize=" + pageSize +
                ", list=" + list +
                ", count=" + getCount() +
                ", start=" + getStart() +
                ", end=" + getEnd() +
                ", nextPage=" + isNextPage() +
                ", shangpage=" + isShangpage() +
                '}';
    }


}
